/*
 * -------------------------------------------------------------------------
 * wav.h -- 
 * Speech Watermarking
 * Copyright (C) 2011-2012  Oriol Parera Fiestas
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 * -------------------------------------------------------------------------
 */


//#include "ALLOC.h"
#include "arq.h"

#include <stdio.h>
#include <stdlib.h>

typedef struct {
  unsigned int soundLength, frequency;
  char *sample;
} WaveData;
 
typedef struct  
   {
     char                RIFF[4];        /* RIFF Header      */ //Magic header
     unsigned long       chunkSize;      /* RIFF Chunk Size  */
     char                WAVE[4];        /* WAVE Header      */
     char                fmt[4];         /* FMT header       */
     unsigned long       cubChunk1Size;  /* Size of the fmt chunk                                */
     unsigned short      audioFormat;    /* Audio format 1=PCM,6=mulaw,7=alaw, 257=IBM Mu-Law, 258=IBM A-Law, 259=ADPCM */
     unsigned short      numOfChan;      /* Number of channels 1=Mono 2=Sterio                   */
     unsigned long       samplesPerSec;  /* Sampling Frequency in Hz                             */
     unsigned long       bytesPerSec;    /* bytes per second */
     unsigned short      blockAlign;     /* 2=16-bit mono, 4=16-bit stereo */
     unsigned short      bitsPerSample;  /* Number of bits per sample      */
     char                subChunk2ID[4]; /* "data"  string   */
     unsigned long       subChunk2Size;  /* Sampled data length    */
   }WAVHeader; 

//WaveData voice;         //Pointer to wave data

FILE* openWAV(const char *filename, const char* mode, WAVHeader * header, unsigned length);
unsigned readWAV (FILE* fd, const unsigned length, void * where);
unsigned saveWAV (FILE* fd, const unsigned length, void *where);
unsigned getLength(FILE* fd);
unsigned getHeader(FILE* fd, WAVHeader ** header);
unsigned putHeader(FILE* fd, WAVHeader * wavHeader, unsigned length);
void closeWAV(FILE** fd);


/* OLD METHODS */


int loadVoice (WaveData *voice, WAVHeader *header, char *FileName);
int saveVoice (WaveData *voice, WAVHeader *header,char *FileName);

int loadSamples(WaveData *voice, char*filename);
int loadHeader (WAVHeader * header,char * filename);
//int getWAVHeader (FILE *,WAVHeader*);
//int getSample (FILE *,WAVHeader*);
//int 



